package com.dyzx.hbb.modules.fcxs.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dyzx.hbb.common.config.MyLambdaQueryWrapper;
import com.dyzx.hbb.modules.fcxs.entity.FcxsDiscount;
import com.dyzx.hbb.modules.fcxs.entity.FcxsPaymentPlan;
import com.dyzx.hbb.modules.fcxs.service.FcxsPaymentPlanService;
import com.dyzx.hbb.modules.fcxs.mapper.FcxsPaymentPlanMapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
* @author Administrator
* @description 针对表【fcxs_payment_plan(缴费计划表)】的数据库操作Service实现
* @createDate 2025-05-20 16:02:42
*/
@Service
public class FcxsPaymentPlanServiceImpl extends ServiceImpl<FcxsPaymentPlanMapper, FcxsPaymentPlan>
    implements FcxsPaymentPlanService{

    @Override
    public List<Map<String, Object>> findByOrderIdList(Long orderId) {
        return this.listMaps(queryInfoWrapper().eq(FcxsPaymentPlan::getOrderId, orderId));
    }

    @Override

    public long findByOrderIdTotal(Long orderId) {
        MyLambdaQueryWrapper<FcxsPaymentPlan> queryWrapper = queryInfoWrapper();
        queryWrapper.sum(FcxsPaymentPlan::getAmt).as("amt").eq(FcxsPaymentPlan::getOrderId, orderId);
        FcxsPaymentPlan one = this.getOne(queryWrapper);
        return one != null ? one.getAmt() : 0;
    }


    protected MyLambdaQueryWrapper<FcxsPaymentPlan> queryInfoWrapper() {
        MyLambdaQueryWrapper<FcxsPaymentPlan> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.select(FcxsPaymentPlan::getId)
                .select(FcxsPaymentPlan::getType)
                .select(FcxsPaymentPlan::getAmt)
                .select(FcxsPaymentPlan::getCreateDate);
        return queryWrapper;
    }
}




